
package com.dd.ms.auth.repository;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dd.ms.auth.mapper.DeptMapper;
import com.dd.ms.auth.mapper.UserMapper;
import com.dd.ms.auth.pojo.DO.DeptDO;
import com.dd.ms.auth.pojo.DO.UserDO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

/**
 * @Author liuxianmeng
 * @CreateTime 2025/7/8 17:42
 * @Description 部门操作仓储层
 */
@Repository
@RequiredArgsConstructor
public class DeptRepository {

    private final DeptMapper deptMapper;

    public Boolean userExists(String deptIdentification) {
        LambdaQueryWrapper<DeptDO> lqw = new LambdaQueryWrapper<>();
        lqw.eq(DeptDO::getDeptIdentification, deptIdentification);
        DeptDO deptDO = deptMapper.selectOne(lqw);
        return null != deptDO;
    }

    public DeptDO get(String deptIdentification) {
        LambdaQueryWrapper<DeptDO> lqw = new LambdaQueryWrapper<>();
        lqw.eq(DeptDO::getDeptIdentification, deptIdentification);
        return deptMapper.selectOne(lqw);
    }

    public void save(DeptDO userDO) {
        deptMapper.insert(userDO);
    }
}
